package com.javaweb.admin.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.javaweb.admin.entity.Scheduled;
import com.javaweb.admin.mapper.ScheduledMapper;
import com.javaweb.admin.service.AbstractJob;
import com.sphsine.bip.IBIPService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Bip2TaxCloudJob
 *
 * @author HanQuinn
 * Date: 2024/2/28
 * Time: 18:13
 */
@Component
@Slf4j
public class Bip2TaxCloudJob  extends AbstractJob {

    @Autowired
    ScheduledMapper scheduledMapper;

    @Autowired
    private IBIPService ibipService;

    @Override
    public String getName() {
        QueryWrapper<Scheduled> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("classpath",this.getClass().getName());
        Scheduled entity = scheduledMapper.selectOne(queryWrapper);
        return entity.getName();
    }

    @Override
    public void execute() {
        log.error("start syncVatInvoice 1528");
        ibipService.syncVatInvoice("1528");
        log.error("end 1528 start syncVatInvoice 1529");
        ibipService.syncVatInvoice("1529");
        log.error("end 1529 start syncVatInvoice 1173");
        ibipService.syncVatInvoice("1173");
        log.error("end syncVatInvoice 1173");
    }
}
